using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace CodRevit.Commands
{
    [Transaction(TransactionMode.Manual)]
    public class ShareParameterCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // 检查是否在族文档中
            Document doc = commandData.Application.ActiveUIDocument.Document;
            if (!doc.IsFamilyDocument)
            {
                TaskDialog.Show("错误", "此命令只能在族文档中使用。");
                return Result.Failed;
            }

            var window = new Views.ShareParameterView();
            var viewModel = new ViewModels.ShareParameterViewModel(commandData.Application, window);
            window.DataContext = viewModel;

            window.ShowDialog();
            return Result.Succeeded;
        }
    }
}